﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Direct.Web.Mvc.Controls2;

namespace Direct.Controls
{
    public class UiApplicationView : UiWidget<UiApplicationView>
    {
        public static readonly ControlProperty TitleProperty = ControlProperty.Register("Title",
            typeof(String),
            typeof(UiApplicationView));
        private UiWidgetHeader _title;
        private UiContentContainer _titleHolder;

        public UiApplicationView()
        {
            _title = new UiWidgetHeader().SetTemplateBinding(UiWidgetHeader.TextProperty, TitleProperty);
            _titleHolder = new UiContentContainer()
                .AddClass("shell-content")
                .AddClass("app-view-title")
                .Add(_title);

        }

        public String Title
        {
            get { return GetValue<String>(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        protected override void RenderContent(string innerText, string rawInnerText)
        {
            _title.ApplyTemplate(this);
            _titleHolder.Render(CurrentContext);

            base.RenderContent(innerText, rawInnerText);
        }

    }
}
